package com.zhanglei.method;

/**
 * @author caesar
 * @date 2025/7/5
 * @apiNote
 */
public class Book {
    private String title;
    private String author;
    private String isbn;
    private double price;

    public Book() {
    }

    public Book(String title, String author, String isbn, double price) {
        this.title = title;
        this.author = author;
        this.isbn = isbn;
        this.price = price;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getIsbn() {
        return isbn;
    }

    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String displayInfo() {
        return "《" + this.title + "》" + "作者：" + this.author + "，ISBN：" + this.isbn + "，价格：" + this.price;
    }

    public double applyDiscount(double discountPercent){
        if (discountPercent >= 0 && discountPercent <= 10) {
            return this.price * discountPercent / 10;
        } else {
            System.out.println("折扣无效，请输入 [0,10] 之间的数值。");
            return this.price;
        }
    }
}
